package com.amit.hibernate;




import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;

public class Lab37 {

	public static void main(String[] args) {
		
			try{
				SessionFactory sf=Chibernateutil.getFactory();
			
			Session session=sf.openSession();
			Transaction tx=session.beginTransaction();
			SID id=SIDGenerator.getNextSid("30");
			Student cust=new Student(id,"amit","amit@gmail.com", "999");
			session.save(cust);
			
			Student stu1=(Student) session.load(Student.class, new SID("30", "001"));
			
			System.out.println(stu1.getStudentId().getBid());
			System.out.println(stu1.getStudentId().getSid());
			System.out.println(stu1.getSname());
			System.out.println(stu1.getEmail());
			System.out.println(stu1.getPhone());
			
			
			
			tx.commit();
			session.close();
		}catch(Exception e){
			e.printStackTrace();
		}
			}
}
